using System;
using System.Runtime.Serialization;

namespace ContinuousDisintegration.Serialization
{
    public class UnattributedTypeSurrogateSelector : ISurrogateSelector
    {
        private readonly SurrogateSelector innerSelector = new SurrogateSelector();
        private readonly Type iFormatter = typeof (IFormatter);

        public void ChainSelector(ISurrogateSelector selector)
        {
            innerSelector.ChainSelector(selector);
        }

        public ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
        {
            if (!type.IsSerializable)
            {
                selector = this;
                return new UnattributedTypeSurrogate();
            }
            return innerSelector.GetSurrogate(type, context, out selector);
        }

        public ISurrogateSelector GetNextSelector()
        {
            return innerSelector.GetNextSelector();
        }
    }
}